using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlateCell : MonoBehaviour
{
    public int numder;

    private BoxCollider2D bc;
    private SpriteRenderer sr;
    private Plates parent;

    //private bool canTrigger = true;
    private void Start()
    {

    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && parent.lastCell != this)
        {
            Active();
            parent.ActiveCell(this);
            parent.lastCell = this;
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        parent.lastCell = null;
    }

    public void Active()
    {
        // sr.color = new Color(185, 100, 179, 255);
        sr.color = new Color(0.7f, 0.7f, 0.7f);
        bc.enabled = false;
    }

    public void Disactive()
    {
        sr.color = new Color(255, 255, 255);
        bc.enabled = true;
    }

    public void GetComponentCell()
    {
        parent = this.GetComponentInParent<Plates>();
        bc = this.GetComponent<BoxCollider2D>();
        sr = this.GetComponent<SpriteRenderer>();
    }
}
